package com.han.adbconnect.utils;


import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.KeyEvent;

public class ProgressUtil {
    private Context mContext;

    private ProgressDialog progressDialog;

    public ProgressUtil(Context paramContext) {
        this.mContext = paramContext;
        this.progressDialog = new ProgressDialog(this.mContext);
        this.progressDialog.getWindow().clearFlags(2);
    }

    public void hide() {
        if (this.progressDialog != null)
            this.progressDialog.dismiss();
    }

    public void setStep(int paramInt) {
        if (this.progressDialog != null) {
            this.progressDialog.setProgress(paramInt);
            if (this.progressDialog.getMax() == paramInt)
                this.progressDialog.dismiss();
        }
    }

    public void show(String paramString) {
        this.progressDialog.setProgressStyle(0);
        this.progressDialog.setMessage(paramString);
        this.progressDialog.setCancelable(false);
        this.progressDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
            public boolean onKey(DialogInterface param1DialogInterface, int param1Int, KeyEvent param1KeyEvent) {
                if (param1Int == 4 && param1KeyEvent.getRepeatCount() == 0) {
                    ProgressUtil.this.progressDialog.dismiss();
                    return true;
                }
                return false;
            }
        });
        this.progressDialog.show();
    }

    public void show(String paramString, int paramInt) {
        this.progressDialog.setProgressStyle(1);
        this.progressDialog.setMessage(paramString);
        this.progressDialog.setCancelable(false);
        this.progressDialog.setMax(paramInt);
        this.progressDialog.show();
    }
}
